package com.zhang.zhangapp.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.zhang.zhangapp.MainActivity;
import com.zhang.zhangapp.R;
import com.zhang.zhangapp.SplashActivity;

/**
 * Created by Administrator on 2018/4/4.
 */

public class GuideFragment extends BaseLazyFragment{

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        ImageView imageView = new ImageView(getActivity());
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        Bundle bundle =getArguments();
        int sourceImage = bundle.getInt("sourceImage");
        imageView.setImageResource(sourceImage);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        if(sourceImage == R.mipmap.guid2){
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    goMain();
                }
            });
        }
        return imageView;
    }

    private void goMain() {
        Intent intent = new Intent(GuideFragment.this.getActivity(), MainActivity.class);
        startActivity(intent);
        GuideFragment.this.getActivity().finish();
    }
}
